package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmNewsSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class WmNewsSensitiveController {

    @Autowired
    private WmNewsSensitiveService wmNewsSensitiveService;

    /**
     * 查询敏感词列表
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDto sensitiveDto) {
        return wmNewsSensitiveService.listSensitiveWords(sensitiveDto);
    }

    /**
     * 新增敏感词
     * @param wmSensitive 敏感词实体
     * @return
     */
    @PostMapping("/save")
    public ResponseResult add(@RequestBody WmSensitive wmSensitive) {
        return wmNewsSensitiveService.addSensitiveWord(wmSensitive);
    }

    /**
     * 删除敏感词
     * @param id 敏感词ID
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return wmNewsSensitiveService.deleteSensitiveWord(id);
    }

    /**
     * 修改敏感词
     * @param wmSensitive 敏感词实体
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {
        return wmNewsSensitiveService.updateSensitiveWord(wmSensitive);
    }
}

